package com.xyrl.project.common.system.vo;


import com.alibaba.fastjson.JSON;
import com.xyrl.common.util.domain.RegexpConstant;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Pattern;
import javax.validation.constraints.Size;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
 * @ClassName DictionaryVo
 * @Description TODO
 * @Author Administrator
 * @Date 2019/12/24 15:52
 * @Version 1.0
 */
@Data
@NoArgsConstructor
public class DictionaryVo implements Comparable<DictionaryVo> {
    /**
     * 数据字典id
     */
    private Long id;
    /**
     * 父级id
     */
    private Long parentId;

    /**
     * 数据字典名称
     */
    @NotBlank(message = "{required}")
    @Size(max = 64, message = "{noMoreThan}")
    private String name;

    /**
     * 数据字典key
     */
    @NotBlank(message = "{required}")
    @Size(max = 48, message = "{noMoreThan}")
    @Pattern(regexp = RegexpConstant.CHARTS, message = "{charts_crossing}")
    private String optionKey;

    /**
     * 数据字典值
     */
    @Size(max = 128, message = "{noMoreThan}")
    private String optionValue;

    /**
     * 显示顺序
     */
    private Integer sort = 0;

    /**
     * 状态值(YES 启用,NO 停用)
     */
    private String status;
    /**
     * 编辑用户id
     */

    private Long userId;


    @Override
    public int compareTo(DictionaryVo dictionaryVo) {
        return this.sort.compareTo(dictionaryVo.getSort());
    }


    public static void main(String[] args) {
        List<DictionaryVo> list = new ArrayList<>();
        DictionaryVo vo = new DictionaryVo();
        vo.setSort(1);
        vo.setName("测试1");


        DictionaryVo vo1 = new DictionaryVo();
        vo1.setSort(2);
        vo1.setName("测试2");
        list.add(vo);
        list.add(vo1);
        Collections.sort(list);
        System.out.println(JSON.toJSON(list));
    }

}
